package com.zzuli.dcxt.controller;

import com.zzuli.dcxt.entiy.Customer;
import com.zzuli.dcxt.service.RegistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/regist")
public class RegistController {
    @Autowired
    private RegistService registService;
    @RequestMapping("/insert")
    public String inset( Customer customer
    ){
        System.out.println("我被访问了");
        System.out.println(customer);
        registService.insertCoustomer(customer);
        return "admin";
    }

    //检查用户名是否存在
    @ResponseBody
    @RequestMapping("/checkNmae")
    public String checkNmae(String name){
        System.out.println("================");
        String nameParam = registService.checkName(name);
        if (nameParam==null){
            System.out.println("====");
            return "true";

        }else {
            System.out.println(nameParam);
            return "false";
        }
    }
}
